import 'package:flutter/material.dart';

class EgBottomNavigation extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return new StateBottomNavigation();
  }
}

class StateBottomNavigation extends State<EgBottomNavigation> {
  int _selectedIndex = 1;
  final _widgetOptions = [new Text("这是第一个页面"), new Text("这是第二个页面"), new Text("这是第三个页面")];

  @override
  Widget build(BuildContext context) {
    return new Scaffold(
      appBar: new AppBar(
        title: new Text("底部切换"),
      ),
      body: Center(
        child: _widgetOptions.elementAt(_selectedIndex),
      ),
      bottomNavigationBar: new BottomNavigationBar(
        items: <BottomNavigationBarItem>[
          new BottomNavigationBarItem(title: new Text("信息"), icon: new Icon(Icons.message)),
          new BottomNavigationBarItem(title: new Text("通讯录"), icon: new Icon(Icons.contacts)),
          new BottomNavigationBarItem(title: new Text("发现"), icon: new Icon(Icons.account_circle)),
        ],
        currentIndex: _selectedIndex,
        fixedColor: Colors.deepOrange,
        onTap: _onItemTapped,
      ),
    );
  }

  void _onItemTapped(int value) {
    setState(() {
      _selectedIndex = value;
    });
  }
}
